package com.zhanghao.sdk.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.zhanghao.sdk.R;
import com.zhanghao.sdk.util.ToastUtils;

public class CustomDialog extends BaseDialogView {
    private static final int BUTTON_ONE = 1;

    public CustomDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void bindLayout() {
        super.bindLayout(R.layout.zh_base_dialog);
    }

    @Override
    protected void initView() {
        super.initView();
        Button mButton = findViewById(R.id.zh_base_dialog_button);
        mButton.setTag(BUTTON_ONE);
        mButton.setOnClickListener(this);
    }

    /**
     * 按钮的点击事件
     */
    private void showTest() {
        ToastUtils.show(mContext,"测试");
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        int tag = (int) v.getTag();
        if (tag == BUTTON_ONE) {// 调用私有方法
            showTest();
        }
    }

    @Override
    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
        return super.onKey(dialog, keyCode, event);
    }

    @Override
    protected boolean onBackKey() {
        return super.onBackKey();
    }

}
